import pandas as pd
import requests
from utils import df_into_db
import json


Binance_spot_base_url = "https://api.binance.com"
exchange_info_api = Binance_spot_base_url + "/api/v3/exchangeInfo"
response = requests.get(exchange_info_api)
data = response.json()
symbols = data['symbols']
symbols_df = pd.DataFrame(symbols)
print(symbols_df.columns)
for column in ['filters', 'orderTypes', 'allowedSelfTradePreventionModes', 'permissions','permissionSets']:
    symbols_df[column] = symbols_df[column].apply(lambda x: json.dumps(x))
df_into_db(symbols_df, "spot_symbols")
